<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>refs 和 parent</title>
</head>
<body>

<div id="app">
    <p>
        {{messge}}
    </p>
    <cpn></cpn>
    <cpn ref="hh"></cpn>
    <cpn></cpn>
    <button @click="getcpn">获取子组件msg</button>
</div>
<template id="cpn">
    <div>
        我是子组件
        {{msg}}
    </div>
</template>
<script src="../js/vue.js"></script>
<script>
  let cpn = {
    template: '#cpn',
    data() {
      return {
        msg: '我是cpn的msg'
      }
    }
  }
  const app = new Vue({
    el: '#app',
    data: {
      messge: '这是信息'
    },
    methods: {
      getcpn(){
        console.log(this.$children);
        console.log(this.$refs.hh.msg);
      }
    },
    components: {
      cpn
    }
  })
</script>


</body>
</html>